<?php 
namespace Admin\Model;
use Think\Model\RelationModel;
class ArticleModel extends RelationModel{     
	protected $tableName = 'article';
	protected $_link = array(
			'attr' =>array(
				'mapping_type'			=>  self::MANY_TO_MANY,
				'mapping_name'  		=>  'attr',
				'foreign_key'      		=>  'article_id',    
				'relation_foreign_key'  =>  'attr_id',
				'relation_table'    	=>  'tb_article_attr',
				),
			'cate' =>array(
				'mapping_type'          => self::BELONGS_TO ,
				'foreign_key'      		=> 'cate_id',
				'mapping_fields'        => 'name',
				'as_fields'             => 'name:cateName',
				),

		);
	public function getArticles($type=0){
		$field = array('del');
		$where = array('del' => $type);
		return $this->field($field,true)->where($where)->relation(true)->select();
	}
}

 ?>